package com.fpt.quanlysanbong.dao;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.fpt.quanlysanbong.domain.TimeDivision;

public class TimeDivisionDao extends BaseDao {
	public TimeDivision getTimeDivisionById(int id) {
		String sql = "Select * From dbo.TimeDivision WHERE id = " + id;
		TimeDivision td = null;
		try {
			ResultSet rs = conn.createStatement().executeQuery(sql);
			if (rs.next()) {
				td = new TimeDivision();
				td.setSoccerField(new SoccerFieldDao().getSoccerFieldByTimeDivision(id));
				td.setId(rs.getInt("id"));
				td.setPeriod(rs.getString("period"));
				td.setPrice(rs.getFloat("price"));
				td.setSubSoccerField(rs.getString("subSoccerField"));
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}

		return td;
	}
}
